<?php require_once('../../Connections/agriculture.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

$maxRows_postersRecordset1 = 10;
$pageNum_postersRecordset1 = 0;
if (isset($_GET['pageNum_postersRecordset1'])) {
  $pageNum_postersRecordset1 = $_GET['pageNum_postersRecordset1'];
}
$startRow_postersRecordset1 = $pageNum_postersRecordset1 * $maxRows_postersRecordset1;

mysql_select_db($database_agriculture, $agriculture);
$query_postersRecordset1 = "SELECT * FROM poster";
$query_limit_postersRecordset1 = sprintf("%s LIMIT %d, %d", $query_postersRecordset1, $startRow_postersRecordset1, $maxRows_postersRecordset1);
$postersRecordset1 = mysql_query($query_limit_postersRecordset1, $agriculture) or die(mysql_error());
$row_postersRecordset1 = mysql_fetch_assoc($postersRecordset1);

if (isset($_GET['totalRows_postersRecordset1'])) {
  $totalRows_postersRecordset1 = $_GET['totalRows_postersRecordset1'];
} else {
  $all_postersRecordset1 = mysql_query($query_postersRecordset1);
  $totalRows_postersRecordset1 = mysql_num_rows($all_postersRecordset1);
}
$totalPages_postersRecordset1 = ceil($totalRows_postersRecordset1/$maxRows_postersRecordset1)-1;

$queryString_postersRecordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_postersRecordset1") == false && 
        stristr($param, "totalRows_postersRecordset1") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_postersRecordset1 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_postersRecordset1 = sprintf("&totalRows_postersRecordset1=%d%s", $totalRows_postersRecordset1, $queryString_postersRecordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<script language="javascript">
	function okToDelete(){
		if(confirm("确定删除?")){
		return true;
		}
	return false;
	}
</script>

<?php

if(isset($_GET['action'])){

$id=$_GET['id'];

$sql="delete from poster where poster_id=".$id;

$result=mysql_query($sql, $agriculture) or die(mysql_error());

}


?>
<body>
<p><a href="bbsadmin.php?type=1">供应信息</a> <a href="bbsadmin.php?type=2">需求信息</a> <a href="bbsadmin.php?type=0">咨询信息</a> <a href="bbsposter.php">用户管理</a></p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">ID</td>
    <td align="center">User</td>
    <td align="center">Pass</td>
    <td align="center">Email</td>
    <td align="center">操作</td>
  </tr>
  <?php do { ?>
    <tr>
      <td align="center"><?php echo $row_postersRecordset1['poster_id']; ?></td>
      <td align="center"><?php echo $row_postersRecordset1['poster_user']; ?></td>
      <td align="center"><?php echo $row_postersRecordset1['poster_pass']; ?></td>
      <td align="center"><?php echo $row_postersRecordset1['poster_email']; ?></td>
      <td align="center"><a href="bbsposter.php?action=delete&amp;id=<?php echo $row_postersRecordset1['poster_id']; ?>" onclick="return okToDelete()">删除</a></td>
    </tr>
    <?php } while ($row_postersRecordset1 = mysql_fetch_assoc($postersRecordset1)); ?>
</table>
<p>
<table border="0" width="50%" align="center">
  <tr>
    <td width="23%" align="center"><?php if ($pageNum_postersRecordset1 > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_postersRecordset1=%d%s", $currentPage, 0, $queryString_postersRecordset1); ?>">第一页</a>
          <?php } // Show if not first page ?>
    </td>
    <td width="31%" align="center"><?php if ($pageNum_postersRecordset1 > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_postersRecordset1=%d%s", $currentPage, max(0, $pageNum_postersRecordset1 - 1), $queryString_postersRecordset1); ?>">上一页</a>
          <?php } // Show if not first page ?>
    </td>
    <td width="23%" align="center"><?php if ($pageNum_postersRecordset1 < $totalPages_postersRecordset1) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_postersRecordset1=%d%s", $currentPage, min($totalPages_postersRecordset1, $pageNum_postersRecordset1 + 1), $queryString_postersRecordset1); ?>">下一页</a>
          <?php } // Show if not last page ?>
    </td>
    <td width="23%" align="center"><?php if ($pageNum_postersRecordset1 < $totalPages_postersRecordset1) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_postersRecordset1=%d%s", $currentPage, $totalPages_postersRecordset1, $queryString_postersRecordset1); ?>">最后页</a>
          <?php } // Show if not last page ?>
    </td>
  </tr>
</table>
</p>
</body>
</html>
<?php
mysql_free_result($postersRecordset1);
?>
